//
//  InfiniteScrollContainerView.h
//
//
//  Created by 郑林琴 on 15/6/21.
//  Copyright (c) 2015年 郑林琴 All rights reserved.
//

#import <UIKit/UIKit.h>
#import "BIPageControl.h"
#import "iCarrouselFlowLayout.h"



typedef enum : NSUInteger {
    iCarrouselPageStyleNone = 0,
    iCarrouselPageStylePageControl = 1,
    iCarrouselPageStyleProgressView,
    iCarrouselPageStyleLabel,
} iCarrouselPageStyle;

#pragma mark - infinite type views

typedef void(^iCarrouselCellConfiguration)(__kindof UICollectionViewCell * cell, NSIndexPath *indexPath);
typedef void(^iCarrouselCellSelection)(NSIndexPath *indexPath);

@interface iCarrouselContainerView : UIView

- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(__kindof UICollectionViewLayout *)layout;
- (void)registerCell:(Class)cellClass;

@property (nonatomic, strong) NSArray *dataArr;
@property (nonatomic, strong) NSArray *smallImages;

@property (nonatomic, strong)   BIPageControl   *pageControl;
@property (nonatomic, readonly) UILabel         *iPageLabel;
@property (nonatomic, assign) iCarrouselPageStyle pageStyle;

//自动滚动 default NO
@property (nonatomic, assign) BOOL autoCarrousel;
@property (nonatomic, assign) CGFloat carrouselInterval;


@property (nonatomic, assign) UIEdgeInsets      containerEdgeInset;


@property (nonatomic, copy  ) iCarrouselCellConfiguration cellConfiguration;
@property (nonatomic, copy  ) iCarrouselCellSelection     select_block_t;

- (UICollectionView *)collectionView;


- (void)showPage:(NSInteger)page animate:(BOOL)animate;

- (void)startCarrousel;
- (void)stopCarrousel;

@end



/** banner view*/
@interface InfiniteScrollView : iCarrouselContainerView

@end




#pragma mark - cell

@interface iCarrouselImageCollectionViewCell : UICollectionViewCell

@property (nonatomic, strong) UIImageView *infiniteImageView;
@property (nonatomic, assign) UIEdgeInsets  contentInset;

@end




CG_INLINE CGRect
CGRectEdgeInset(CGRect frame, UIEdgeInsets inset){
    CGRect f = frame;
    f.origin.x = inset.left;
    f.origin.y = inset.top;
    f.size.width -= inset.left + inset.right;
    f.size.height -= inset.top + inset.bottom;
    return f;
}

//@interface SmallItemScrollView : iCarrouselContainerView
//
//@end

